package net.mcreator.magicio.procedures;

import net.minecraft.world.IWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.tags.BlockTags;

import net.mcreator.magicio.MagicIoMod;

import java.util.Map;
import java.util.HashMap;

public class BlockGrowingProcedure {
	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("x") == null) {
			if (!dependencies.containsKey("x"))
				MagicIoMod.LOGGER.warn("Failed to load dependency x for procedure BlockGrowing!");
			return;
		}
		if (dependencies.get("y") == null) {
			if (!dependencies.containsKey("y"))
				MagicIoMod.LOGGER.warn("Failed to load dependency y for procedure BlockGrowing!");
			return;
		}
		if (dependencies.get("z") == null) {
			if (!dependencies.containsKey("z"))
				MagicIoMod.LOGGER.warn("Failed to load dependency z for procedure BlockGrowing!");
			return;
		}
		if (dependencies.get("world") == null) {
			if (!dependencies.containsKey("world"))
				MagicIoMod.LOGGER.warn("Failed to load dependency world for procedure BlockGrowing!");
			return;
		}
		double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
		double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
		double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
		IWorld world = (IWorld) dependencies.get("world");
		double fx = 0;
		double fy = 0;
		double fz = 0;
		double nx = 0;
		double nz = 0;
		fx = (double) Math.floor((x - 8));
		fy = (double) Math.floor((y - 8));
		fz = (double) Math.floor((z - 8));
		nx = (double) fx;
		nz = (double) fz;
		for (int index0 = 0; index0 < (int) (16); index0++) {
			for (int index1 = 0; index1 < (int) (16); index1++) {
				for (int index2 = 0; index2 < (int) (16); index2++) {
					if ((BlockTags.getCollection().getTagByID(new ResourceLocation(("forge:oreblock").toLowerCase(java.util.Locale.ENGLISH)))
							.contains((world.getBlockState(new BlockPos((int) fx, (int) fy, (int) fz))).getBlock()))) {
						{
							Map<String, Object> $_dependencies = new HashMap<>();
							$_dependencies.put("world", world);
							$_dependencies.put("x", fx);
							$_dependencies.put("y", fy);
							$_dependencies.put("z", fz);
							GrowingProcedure.executeProcedure($_dependencies);
						}
					}
					fx = (double) (fx + 1);
				}
				fx = (double) nx;
				fz = (double) (fz + 1);
			}
			fz = (double) nz;
			fy = (double) (fy + 1);
		}
	}
}
